package com.chengh.springboot.dynamicdatasource.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chengh.springboot.dynamicdatasource.annotation.DataSource;
import com.chengh.springboot.dynamicdatasource.mapper.UserMapper;
import com.chengh.springboot.dynamicdatasource.pojo.User;
import com.chengh.springboot.dynamicdatasource.service.IUserService;
import com.chengh.springboot.dynamicdatasource.utils.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户信息表 服务实现类
 * </p>
 *
 * @author chengh
 * @since 2021-10-28
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Boolean addUser(User user) {
        int insert = userMapper.insert(user);
        return insert > 0;
    }
}
